package com.tiaoshi.thenwhat.common.entity.common;

import java.util.Date;

import lombok.Getter;
import lombok.Setter;

/**
 * The general operation result for every action.
 * 
 * @author jianli
 * 
 * @param <T>
 */
@Getter
@Setter
//@JsonInclude(Include.NON_NULL)
public class GeneralResult {
	private int returnCode = 0;
	private String message = "success";
	private Date date = new Date();
	private Object result;
	private Integer errorCode;
	
	// 0 成功，1失败,2特殊提示
	public enum ReturnCode {
		Success, Failure,NOTICE
	}

	public void setException(java.lang.Throwable ex) {
		
	}

	public static class Builder {
		private GeneralResult result = new GeneralResult();

		public Builder setResult(Object data) {
			result.setResult(data);
			return this;
		}

		public Builder setException(Exception e) {
			result.setException(e);
			return this;
		}

		public GeneralResult getResponse() {
			return result;
		}
	}

	public static Builder newBuilder() {
		return new Builder();
	}
}
